package codegen.groovy.graphnetwork.model;

import java.util.ArrayList;

/**
 *
 * @author hungcuong
 */
public class Value {

    public String type;
    String name;
    public float value;
    //Value linkedValue;
    public Link link;
    public Node parent;
    public boolean linked;
    public boolean changable;
    public boolean isInput=true;
    public boolean defaultPin=false;
    
    ArrayList<ValueChangeListener> listeners = new ArrayList<ValueChangeListener>();
    public Status status;
    enum Status {
        Init,Computing,Finished
    }
    
    public Value(String type, String name, float value) {
        this.type = type;
        this.name = name;
        this.value = value;
    }

    public void addChangeListener(ValueChangeListener listener) {
        listeners.add(listener);
    }

    public void onChange() {
        for (ValueChangeListener l : listeners) {
            l.onChange();
        }
    }
    
    def getValue(){
        return this.value;
    }
    
    def getLinkedValue(){
        this.value= this.link.input.value;
        this.status=Status.Finished;
    }
}
